package com.romotc.qqrobot.webqq.qqInterfaceCall;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.scache.httpreq;
/**
 * http://d.web2.qq.com/channel/get_cface2*获取图片
 * @author Administrator
 *
 */
public class Get_cface2_InterCall extends QQInterfaceCall {

	public static final String Key_Must_Input_Lcid = Get_file2_InterCall.Key_Must_Input_Lcid;
	public static final String Key_Must_Input_FileName = Get_file2_InterCall.Key_Must_Input_FileName;
	public static final String Key_Input_Must_senderUin = Get_file2_InterCall.Key_Must_Input_SenderUin;

	@Override
	public String buildReqBody(JSONObject reqDataObj, QQLogedin loginQQ)
			throws Exception {
		return null;
	}

	@Override
	public int getLogLevel() {
		return 1001;
	}

	@Override
	public String getReqUrl(JSONObject reqDataObj, QQLogedin loginQQ)
			throws JSONException {
		// http://d.web2.qq.com/channel/get_cface2?lcid=8100&guid=B2E65F3437F751D86F57020F314BFD14.jpg
			//&to=3752114008【发送者对应的UIN】&count=5&time=1
		    //&clientid=24746398&psessionid=8368046764001d636f6e6e7365727665725f77656271714031302e3133342e362e3133380000238300001395036e0400d8e8885e6d0000000a4062486570506a4f54626d0000002805c85907980af48ae7666fdc74a66f5c03d1ffe85a186a7aa00ca360948f7edd3957dfa1e3d26260
		 
		return "http://d.web2.qq.com/channel/get_cface2?lcid="
					+ reqDataObj.getInt(Key_Must_Input_Lcid)
					+ "&guid=" + reqDataObj.getString(Key_Must_Input_FileName)
					+ "&to=" + reqDataObj.getLong(Key_Input_Must_senderUin)
					+ "&count=5&timem=1&clientid=" + loginQQ.getClientId()
					+ "&psessionid=" + loginQQ.getPsessionid();
	}

	@Override
	public int getReq_method() {
		return httpreq.REQUEST_GET;
	}

	@Override
	public boolean hasPreCall(QQLogedin loginQQ, JSONObject reqDataObj) {
		return false;
	}

	@Override
	public ArrayList<String> myReqHeaders(int reqBodyLen, QQLogedin loginQQ,JSONObject reqDataObj) {
		ArrayList<String> s = buildReqHeaders(loginQQ,
				"http://web.qq.com/", 
				"d.web2.qq.com");
		return s;
	}

	@Override
	public JSONObject preCall(QQLogedin loginQQ, JSONObject reqDataObj)
			throws Exception {
		return null;
	}


	private static Get_cface2_InterCall instance;
	public static synchronized Get_cface2_InterCall getInstance() {
		if(instance == null)
			instance = new Get_cface2_InterCall();
		return instance;
	}

}
